home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 8 code / Curves in Quickdraw / QD Curves / sfnt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-10-09  |  7.1 KB  |  252 lines  |  [TEXT/MPS ]

  1. #ifndef sfntIncludes
  2. #define sfntIncludes
  3.  
  4. #ifndef Fixed
  5.     #define Fixed    long
  6. #endif
  7.  
  8. #ifndef sfntEnumIncludes
  9.     #include "sfnt_enum.h"
  10. #endif
  11.  
  12. typedef struct {
  13.     unsigned long bc;
  14.     unsigned long ad;
  15. } BigDate;
  16.  
  17. typedef struct {
  18.     unsigned long    tableTag;
  19.     unsigned long    checkSum;
  20.     unsigned long    offset;
  21.     unsigned long    length;
  22. } sfnt_DirectoryEntry;
  23.  
  24. #define SFNT_VERSION    0x10000
  25.  
  26. /*
  27.  *    The search fields limits numOffsets to 4096.
  28.  */
  29. typedef struct {
  30.     Fixed version;                    /* 1.0 */
  31.     unsigned short numOffsets;        /* number of tables */
  32.     unsigned short searchRange;        /* (max2 <= numOffsets)*16 */
  33.     unsigned short entrySelector;        /* log2(max2 <= numOffsets) */
  34.     unsigned short rangeShift;            /* numOffsets*16-searchRange*/
  35.     sfnt_DirectoryEntry table[1];        /* table[numOffsets] */
  36. } sfnt_OffsetTable;
  37.  
  38. #define OFFSETTABLESIZE        12        /* not including any entries */
  39.  
  40. typedef enum sfntHeaderFlagBits {
  41.     Y_POS_SPECS_BASELINE = 1,
  42.     X_POS_SPECS_LSB = 2,
  43.     HINTS_USE_POINTSIZE = 4,
  44.     USE_INTEGER_SCALING = 8,
  45.     INSTRUCTIONS_CHANGE_ADVANCEWIDTHS = 16,
  46.     X_POS_SPECS_BASELINE = 32,
  47.     Y_POS_SPECS_TSB = 64
  48. } sfntHeaderFlagBits;
  49.  
  50. #define SFNT_MAGIC                    0x5F0F3CF5
  51. #define SHORT_INDEX_TO_LOC_FORMAT        0
  52. #define LONG_INDEX_TO_LOC_FORMAT        1
  53. #define GLYPH_DATA_FORMAT                0
  54. #define FONT_HEADER_VERSION            0x10000
  55.  
  56. typedef struct {
  57.     Fixed        version;            /* for this table, set to 1.0 */
  58.     Fixed        fontRevision;        /* For Font Manufacturer */
  59.     unsigned long    checkSumAdjustment;
  60.     unsigned long    magicNumber;         /* signature, should always be 0x5F0F3CF5  == MAGIC */
  61.     unsigned short    flags;
  62.     unsigned short    unitsPerEm;        /* Specifies how many in Font Units we have per EM */
  63.  
  64.     BigDate        created;
  65.     BigDate        modified;
  66.  
  67.     /** This is the font wide bounding box in ideal space
  68.     (baselines and metrics are NOT worked into these numbers) **/
  69.     short        xMin;
  70.     short        yMin;
  71.     short        xMax;
  72.     short        yMax;
  73.  
  74.     unsigned short        macStyle;            /* macintosh style word */
  75.     unsigned short        lowestRecPPEM;     /* lowest recommended pixels per Em */
  76.  
  77.     /* 0: fully mixed directional glyphs, 1: only strongly L->R or T->B glyphs, 
  78.        -1: only strongly R->L or B->T glyphs, 2: like 1 but also contains neutrals,
  79.        -2: like -1 but also contains neutrals */
  80.     short        fontDirectionHint;
  81.  
  82.     short        indexToLocFormat;
  83.     short        glyphDataFormat;
  84. } sfnt_FontHeader;
  85.  
  86. #define METRIC_HEADER_FORMAT        0x10000
  87.  
  88. typedef struct {
  89.     Fixed        version;                /* for this table, set to 1.0 */
  90.     short        ascender;
  91.     short        descender;
  92.     short        lineGap;                /* linespacing = ascender - descender + linegap */
  93.     unsigned short    advanceMax;    
  94.     short        sideBearingMin;        /* left or top */
  95.     short        otherSideBearingMin;    /* right or bottom */
  96.     short        extentMax;             /* Max of ( SB[i] + bounds[i] ), i loops through all glyphs */
  97.     short        caretSlopeNumerator;
  98.     short        caretSlopeDenominator;
  99.     short        caretOffset;
  100.  
  101.     unsigned long    reserved1, reserved2;    /* set to 0 */
  102.  
  103.     short        metricDataFormat;        /* set to 0 for current format */
  104.     unsigned short    numberLongMetrics;        /* if format == 0 */
  105. } sfnt_MetricsHeader;
  106.  
  107. typedef sfnt_MetricsHeader sfnt_HorizontalHeader;
  108. typedef sfnt_MetricsHeader sfnt_VerticalHeader;
  109.  
  110. #define MAX_PROFILE_VERSION        0x10000
  111.  
  112. typedef struct {
  113.     Fixed            version;                /* for this table, set to 1.0 */
  114.     unsigned short        numGlyphs;
  115.     unsigned short        maxPoints;            /* in an individual glyph */
  116.     unsigned short        maxContours;            /* in an individual glyph */
  117.     unsigned short        maxCompositePoints;    /* in an composite glyph */
  118.     unsigned short        maxCompositeContours;    /* in an composite glyph */
  119.     unsigned short        maxElements;            /* set to 2, or 1 if no twilightzone points */
  120.     unsigned short        maxTwilightPoints;        /* max points in element zero */
  121.     unsigned short        maxStorage;            /* max number of storage locations */
  122.     unsigned short        maxFunctionDefs;        /* max number of FDEFs in any preprogram */
  123.     unsigned short        maxInstructionDefs;        /* max number of IDEFs in any preprogram */
  124.     unsigned short        maxStackElements;        /* max number of stack elements for any individual glyph */
  125.     unsigned short        maxSizeOfInstructions;    /* max size in bytes for any individual glyph */
  126.     unsigned short        maxComponentElements;    /* number of glyphs referenced at top level */
  127.     unsigned short        maxComponentDepth;    /* levels of recursion, 1 for simple components */
  128. } sfnt_maxProfileTable;
  129.  
  130.  
  131. typedef struct {
  132.     unsigned short    advance;
  133.     short     sideBearing;
  134. } sfnt_GlyphMetrics;
  135.  
  136. typedef sfnt_GlyphMetrics sfnt_HorizontalMetrics;
  137. typedef sfnt_GlyphMetrics sfnt_VerticalMetrics;
  138.  
  139. typedef short sfnt_ControlValue;
  140.  
  141. /*
  142.  *    Char2Index structures, including platform IDs
  143.  */
  144. typedef struct {
  145.     unsigned short    format;
  146.     unsigned short    length;
  147.     unsigned short    version;
  148. } sfnt_mappingTable;
  149.  
  150. typedef struct {
  151.     unsigned short    platformID;
  152.     unsigned short    specificID;
  153.     unsigned long    offset;
  154. } sfnt_platformEntry;
  155.  
  156. typedef struct {
  157.     unsigned short    version;
  158.     unsigned short    numTables;
  159.     sfnt_platformEntry platform[1];    /* platform[numTables] */
  160. } sfnt_char2IndexDirectory;
  161. #define SIZEOFCHAR2INDEXDIR        4
  162.  
  163. typedef struct {
  164.     unsigned short platformID;
  165.     unsigned short specificID;
  166.     unsigned short languageID;
  167.     unsigned short nameID;
  168.     unsigned short length;
  169.     unsigned short offset;
  170. } sfnt_NameRecord;
  171.  
  172. typedef struct {
  173.     unsigned short format;
  174.     unsigned short count;
  175.     unsigned short stringOffset;
  176. /*    sfnt_NameRecord[count]    */
  177. } sfnt_NamingTable;
  178.  
  179. #define DEVWIDTHEXTRA    2    /* size + max */
  180. /*
  181.  *    Each record is n+2 bytes, padded to long word alignment.
  182.  *    First byte is ppem, second is maxWidth, rest are widths for each glyph
  183.  */
  184. typedef struct {
  185.     short                version;
  186.     short                numRecords;
  187.     long                recordSize;
  188.     /* Byte widths[numGlyphs+DEVWIDTHEXTRA] * numRecords */
  189. } sfnt_DeviceMetrics;
  190.  
  191. #define    stdPostTableFormat        0x10000
  192. #define    wordPostTableFormat    0x20000
  193. #define    bytePostTableFormat    0x28000
  194. #define    richardsPostTableFormat    0x30000
  195.  
  196. typedef struct {
  197.     Fixed    version;
  198.     Fixed    italicAngle;
  199.     short    underlinePosition;
  200.     short    underlineThickness;
  201.     short    isFixedPitch;
  202.     short    pad;
  203.     unsigned long    minMemType42;
  204.     unsigned long    maxMemType42;
  205.     unsigned long    minMemType1;
  206.     unsigned long    maxMemType1;
  207. /* if version == 2.0
  208.     {
  209.         numberGlyphs;
  210.         unsigned short[numberGlyphs];
  211.         pascalString[numberNewNames];
  212.     }
  213.     else if version == 2.5
  214.     {
  215.         numberGlyphs;
  216.         int8[numberGlyphs];
  217.     }
  218. */        
  219. } sfnt_PostScriptInfo;
  220.  
  221. typedef enum outlinePacking {
  222.     ONCURVE = 1,
  223.     XSHORT = 2,
  224.     YSHORT = 4,
  225.     REPEAT_FLAGS = 8,
  226. /* IF XSHORT */
  227.     SHORT_X_IS_POS = 16,        /* the short vector is positive */
  228. /* ELSE */
  229.     NEXT_X_IS_ZERO = 16,        /* the relative x coordinate is zero */
  230. /* ENDIF */
  231. /* IF YSHORT */
  232.     SHORT_Y_IS_POS = 32,        /* the short vector is positive */
  233. /* ELSE */
  234.     NEXT_Y_IS_ZERO = 32        /* the relative y coordinate is zero */
  235. /* ENDIF */
  236. } outlinePacking;
  237.  
  238. typedef enum componentPacking {
  239.     COMPONENTCTRCOUNT = -1,
  240.     ARG_1_AND_2_ARE_WORDS = 1,        /* if not, they are bytes */
  241.     ARGS_ARE_XY_VALUES = 2,            /* if not, they are points */
  242.     ROUND_XY_TO_GRID = 4,
  243.     WE_HAVE_A_SCALE = 8,                /* if not, Sx = Sy = 1.0 */
  244.     NON_OVERLAPPING = 16,
  245.     MORE_COMPONENTS = 32,            /* if not, this is the last one */
  246.     WE_HAVE_AN_X_AND_Y_SCALE = 64,    /* Sx != Sy */
  247.     WE_HAVE_A_TWO_BY_TWO = 128,        /* t00, t01, t10, t11 */
  248.     WE_HAVE_INSTRUCTIONS = 256,        /* short count followed by instructions follows */
  249.     USE_MY_METRICS = 512                /* use my metrics for parent glyph */
  250. } componentPacking;
  251.  
  252. #endif